﻿using CKS2320.Common.Model;
using CKS2320.Service;
using CKS2320.Service.Interface;
using Microsoft.AspNetCore.Mvc;

namespace CKS2320.WebApi.Controllers
{
    /// <summary>
    /// 
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class EquipmentfailureController : ControllerBase
    {
        private IEquipmentfailureService _equipmentfailureService;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="equipmentfailureService"></param>
        public EquipmentfailureController(IEquipmentfailureService equipmentfailureService)
        {
            _equipmentfailureService = equipmentfailureService;
        }
        /// <summary>
        /// 获取故障码表
        /// </summary>
        /// <param name="ip"></param>
        /// <returns></returns>
        [HttpPost("GetEquipmentfailures")]
        public IActionResult GetEquipmentfailures(string ip)
        {
            return Ok(_equipmentfailureService.GetEquipmentfailures(ip));
        }
        /// <summary>
        /// 更新一条故障记录
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet("EditHistory")]
        public IActionResult EditHistory(string id)
        {
            return Ok(_equipmentfailureService.EditHistory(id));
        }
        /// <summary>
        /// 新增一条故障记录
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpPost("InsertHistory")]
        public IActionResult InsertHistory(EquipmentfailurehistoryModel req)
        {
            return Ok(_equipmentfailureService.InsertHistory(req));
        }
        /// <summary>
        /// 新增一条故障记录
        /// </summary>
        /// <returns></returns>
        [HttpGet("GetEquipmentfailureHistory")]
        public IActionResult GetEquipmentfailureHistory(string Language = "CN")
        {
            return Ok(_equipmentfailureService.GetEquipmentfailureHistory(Language));
        }
        /// <summary>
        /// 获取正在故障阶段的记录
        /// </summary>
        /// <returns></returns>
        [HttpGet("GetFailureHistory")]
        public IActionResult GetFailureHistory(string ip)
        {
            return Ok(_equipmentfailureService.GetFailureHistory(ip, "CN"));
        }
    }
}
